//  检查报告(上传)
//  CheckReportViewController.m
//  yilutongxing
//
//  Created by  Mac on 2017/5/7.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import "CheckReportViewController.h"
#import "DzyImgPicker.h"

@interface CheckReportViewController ()<DzyImgDelegate>
@property (weak, nonatomic) IBOutlet UIView *backView;
@property(nonatomic,strong)DzyImgPicker *DzyView;
@property (nonatomic ) NSMutableArray *data;

@end

@implementation CheckReportViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title=@"上传报告";
    self.automaticallyAdjustsScrollViewInsets=NO;
    self.navigationItem.rightBarButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"确定" style:UIBarButtonItemStylePlain target:self action:@selector(fabu)];
    
    UIImage *leftImage=[[UIImage imageNamed:@"返回"]imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIBarButtonItem *leftButtonItem=[[UIBarButtonItem alloc]initWithImage:leftImage style:UIBarButtonItemStylePlain target:self action:@selector(back)];
    self.navigationItem.leftBarButtonItem=leftButtonItem;
    
    [self layoutDzyView];
}

-(void)layoutDzyView{
    
    self.data = [NSMutableArray array];
    //此处需要注意  自己计算一下  我设置的每个cell 是60*60  间距10 所以 这里一般是设置 全屏宽度  如有特殊需求自行修改
    
    self.DzyView = [[DzyImgPicker alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, 115) andParentV:self andMaxNum:3];
    self.DzyView.dzyImgDelegate = self;
    self.DzyView.collectionView.scrollEnabled=NO;
    [self.backView addSubview:self.DzyView];
    
    __weak typeof(self)weakSelf = self;
    [self.DzyView setDzyImgs:^(NSArray *data) {
        NSLog(@"block --- %lu",(unsigned long)data.count);
        weakSelf.data = [data mutableCopy];
       // if (weakSelf.data.count>=4) {
        //    weakSelf.DzyView.collectionView.frame=CGRectMake(0, 0, SCREEN_WIDTH, 220);
       // }
       // if (weakSelf.data.count<4) {
         //   weakSelf.DzyView.collectionView.frame=CGRectMake(0, 0, SCREEN_WIDTH, 128);
       // }
    }];
}
- (void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    //从相册返回的话需要刷新下界面
    [_DzyView.collectionView reloadData];
    
}


//代理方式返回数组
- (void)getImages:(NSArray *)imgData{
    NSLog(@"imgData = = = =  7868 7678 = = %@",imgData);
}
-(void)back{
    [self dismissViewControllerAnimated:YES completion:nil];
}

-(void)fabu{
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
